from selenium.webdriver.common.by import By
from pages.base_page import BasePage
from config.config import HOST

class EditTaskPage(BasePage):
    # 添加应收款页面url
    url='http://{}/crm/index.php?m=task&a=edit&id=9'.format(HOST)

    # 定位状态下拉框
    select_status_locator = (By.NAME, 'status')
    # 定位保存按钮
    edit_save_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tfoot > tr > td:nth-child(2) > input.btn.btn-primary')
    # 定位主题
    edit_subject_locator = (By.NAME, 'subject')
    # 定位取消按钮
    edit_cancel_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tfoot > tr > td:nth-child(2) > input:nth-child(2)')

    # 点击状态下拉框
    def click_status(self):
        status=self.driver.find_element(*self.select_status_locator)
        return status

    # 点击保存
    def click_edit_save(self):
        self.driver.find_element(*self.edit_save_locator).click()

    # 修改主题
    def edit_input_subject(self,subject):
        subject_element=self.driver.find_element(*self.edit_subject_locator)
        subject_element.clear()
        subject_element.send_keys(subject)

    # 点击取消
    def click_edit_cancel(self):
        self.driver.find_element(*self.edit_cancel_locator).click()